<template>
  <div>
    <div class="top">
      <Topnav title="我的关注" @click.native="$router.push('/proindex')" />
    </div>
    <div class="tb" v-for="user in followlist" :key="user.id">
      <img
        v-if="user.head_img"
        :src="$axios.defaults.baseURL + user.head_img"
        alt=""
      />
      <img v-else src="@/assets/5.jpg" alt="" />
      <div class="info">
        <div class="infoT">{{ user.nickname }}</div>
        <span class="date">2019-10-10</span>
      </div>
      <div class="follow" @click="unfollow(user.id)">取消关注</div>
    </div>
  </div>
</template>

<script>
import Topnav from "../../components/Topnav.vue";
export default {
  components: {
    Topnav,
  },
  data() {
    return {
      followlist: [],
    }; 
  },
  created() {
    this.loadPage();
  },
  methods: {
    loadPage() {
      this.$axios({
        url: "/user_follows",
      }).then((res) => {
        console.log(res.data);
        const { data } = res.data;
        this.followlist = data;
        console.log(1111);
      });
    },
    unfollow(userid) {
      this.$axios({
        url: "/user_unfollow/" + userid,
      }).then((res) => {
        console.log(res.data);
        this.loadPage()
      });
    },
  },
};
</script>

<style lang="less" scoped>
.top {
  padding: 0 20/360 * 100vw;
}
.tb {
  padding: 10/360 * 100vw 20/360 * 100vw;
  height: 60/360 * 100vw;
  display: flex;
  align-items: center;
  img {
    width: 40/360 * 100vw;
    height: 40/360 * 100vw;
    border-radius: 50%;
    background-color: pink;
    object-fit: cover;
  }
  .info {
    flex: 1;
    font-size: 10/360 * 100vw;
    padding-left: 20/360 * 100vw;
    span {
      color: #333;
    }
  }
  .follow {
    height: 24/360 * 100vw;
    width: 60/360 * 100vw;
    background-color: #e0e0e0;
    border-radius: 12/360 * 100vw;
    line-height: 26/360 * 100vw;
    text-align: center;
    font-size: 8/360 * 100vw;
    font-weight: 700;
    color: #333;
  }
}
</style>